# -*- coding: utf-8 -*-
# @Time    : 2021/12/20 15:50
# @Author  : ydh
# @File    : BookSection.py
# @Software: PyCharm
"""
book 章节
"""
from django.db import models
from django.db.models import CASCADE

from apps.vadmin.models.models import CoreModel


class BookSection(CoreModel):
    section_id = models.CharField(verbose_name="章节", max_length=255, null=True, blank=True)
    section_title = models.CharField(verbose_name="章节标题", max_length=255, null=True, blank=True)
    section_content = models.TextField(verbose_name="章节内容", null=True, blank=True)
    book = models.ForeignKey(
        to="book.BookInfo",
        to_field="id",
        on_delete=CASCADE,
        verbose_name="关联表book表的book_name字段",
        db_constraint=False,
        null=True,
    )

    class Meta:
        db_table = "Tab_Section"
        verbose_name = "章节信息"

    def __str__(self):
        return f"第{self.section_id}章: {self.section_title}"
